package com.huangd.platform.common.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

public class DownloadService {

	private ExecutorService executorService = null;

	private static class Holder {
		private static DownloadService singleton = new DownloadService();
	}

	private DownloadService() {
		executorService = Executors.newFixedThreadPool(16, new ThreadFactory() {
			@Override
			public Thread newThread(Runnable r) {
				Thread thread = new Thread(r);
				thread.setDaemon(true);
				thread.setName("下载线程:" + thread.getId());
				return thread;
			}
		});
	}

	public static DownloadService getInstance() {
		return Holder.singleton;
	}

	public void destroy() {
		executorService.shutdownNow();
	}

	public ExecutorService getExecutorService() {
		return executorService;
	}

}
